package com.outsider.tool.rsa;
import java.util.ArrayList;
import java.util.List;
/**
 * 线性筛素数工具类 
 * O(n)
 * @author outsider
 */
public class Prime {
   public static Integer[] getPrime(int length){             //线性筛素数
		   boolean bo[]=new boolean[length];
		   for (int i=0;i<bo.length;i++)
			   bo[i]=false;
		   List<Integer> primeList=new ArrayList();
		   for (int i=2;i<bo.length;i++){
			   if (bo[i]==false) primeList.add(i);
		       for (Integer j:primeList)
			     if (i*j<bo.length)
			        bo[i*j]=true;
			   else break;
		   }	
		   return primeList.toArray(new Integer[0]);
   }
}
